package com.os.mapper;

import com.os.model.Country;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/**
 * @Author Matt
 * @Date 2022-07-08
 * @Desc:
 * @Version V1.0
 */
public class CountryMapperTestNew extends BaseMapperTest {

    @Test
    public void testSelectAll(){
        SqlSession sqlSession = getSqlSession();
        try {
            List<Country> countryList = sqlSession.selectList("com.os.mapper.CountryMapper.selectAll");
            printCountryList(countryList);
        }finally {
            //不要忘记关闭sqlSession
            sqlSession.close();
        }
    }

    private void printCountryList(List<Country> countryList){
        for(Country country : countryList){
            System.out.printf("%-4d%4s%4s\n", country.getId(), country.getCountryName(), country.getCountryCode());
        }
    }


}
